const app = getApp();
const http = require('../../utils/wx_request').default;

// var appid = wxd0ca93eee80dcdc3

Page({
  data: {
    modalName: false, // true
    navHeight: app.globalData.navHeight,
    MenuButtonHeight: app.globalData.MenuButtonHeight,
    navTop: app.globalData.navTop,
    enuButtonHeight: app.globalData.enuButtonHeight,
    area: wx.getStorageSync('site').district,
    weather: wx.getStorageSync("weather"),
    // combo: [{
    //   image: '/img/taocan1@2x.png',
    //   name: '冬季洗护套餐',
    //   tags: '明星套餐',
    //   price: '120',
    //   yuanPrice: 135,
    //   num: 4
    // }, {
    //   image: '/img/taocan2@2x.png',
    //   name: '冬季洗护套餐',
    //   tags: '明星套餐',
    //   price: '120',
    //   yuanPrice: 135,
    //   num: 4
    // }],
    combos: []
  },

  onLoad() {
    this.homeList()
    let weather = this.data.weather;
    let str = '';
    weather.originalData.results[0].index[1].des;
    for (let i of weather.originalData.results[0].index[1].des) {
      if (i != '，') {
        str += i;
      } else {
        break;
      }
    }
    weather.originalData.results[0].index[1].des = str;
    this.setData({
      weather: weather
    })
  },

  // 首页
  homeList() {
    let me = this.data
    http.home({
      client_appid: wx.getStorageSync('appid')
    }).then(res => {
      let { data: { data } } = res
      this.setData({
        combos: data
      })
    })
  },

  // 一键救援
  sos() {
    wx.navigateTo({
      url: '/pages/index/onesos/onesos'
    })
  },

  // 服务
  yeyu(e) {
    wx.navigateTo({
      url: '/pages/index/make/make?tabId=' + e.currentTarget.dataset.index,
    })
  },

  // 一键预约
  make() {
    wx.navigateTo({
      url: '/pages/index/order/order'
    })
  },

  // 查看带服务订单
  moldShow() {
    this.setData({
      modalName: true
    })
  },

  // 关闭带服务订单
  moldhide() {
    this.setData({
      modalName: false
    })
  }
})
